'
该场景为局内升级时界面
'

extends CanvasLayer

signal upgrade_selected(upgrade: AbilityUpgrade)#卡片被选择时，发送卡片信息信号

@export var upgrade_card_scene: PackedScene
@onready var card_container: HBoxContainer = $"%CardContainer"


func _ready() -> void:
	self.get_tree().paused = true
	pass

#设置填充卡片
func set_ability_upgrades(upgrades: Array[AbilityUpgrade]) -> void:
	var delay = 0
	for upgrade in upgrades:
		var carde_insrance = upgrade_card_scene.instantiate()
		card_container.add_child(carde_insrance)
		carde_insrance.play_in(delay)
		carde_insrance.set_ability_upgrade(upgrade)
		carde_insrance.selected.connect(on_upgrade_selected.bind(upgrade))
		delay += .15
	pass

#卡片被选择后，发送选择的卡片信息
func on_upgrade_selected(upgrade: AbilityUpgrade) -> void:
	upgrade_selected.emit(upgrade)
	$AnimationPlayer.play("out")
	await $AnimationPlayer.animation_finished
	self.get_tree().paused = false
	self.queue_free()
	pass
